package bz.ziro.kanbe.controller;

import java.io.StringWriter;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import bz.ziro.kanbe.bean.ParamData;
import bz.ziro.kanbe.logic.HtmlLogic;

/**
 * ページ表示用コントローラー
 * @author Administrator
 */
public class IndexController extends Controller {

    @Override
    public Navigation run() {
        //指定IDを取得
        String keyBuf = requestScope("id");
        String pageNum = requestScope("page");
        String childNum = requestScope("child");
        
        //引数データを作成
        ParamData data = new ParamData();
        data.setId(keyBuf);
        data.setPageNum(pageNum);
        data.setChildrenNum(childNum);
        data.setLocale(request.getLocale());
        
        StringWriter html = new StringWriter();
        //サイトデータを作成する
        String forward = HtmlLogic.createHtml(null,data,request,html);
        //HTMLを設定する
        requestScope("html",html);

        return forward(forward);
    }
}
